import Imagelocation from '@/components/Imagelocation';
import pNotice from '@/images/common/notice.png';
import pTuancanbiaoqian from '@/images/common/tuancanbiaoqian.png';
import pStar from '@/images/taihuHomePage/star.png';
import { Image, Text, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import React from 'react';
import './shopList.scss';

const ShopList = ({ dataList = [] }) => {
  const goShopDetail = (shopId) => {
    let url = '/mainSubPack/shopInfo/index?orgId=' + shopId;
    Taro.navigateTo({
      url,
    });
  };

  return (
    <View className="TimelineShopList">
      {dataList.length > 0 &&
        dataList.map((shop) => (
          <View
            className="shop localOrg"
            key={'localOrgShop' + shop.id}
            onClick={() => goShopDetail(shop.id)}
          >
            {shop.activityList &&
              shop.activityList.length > 0 &&
              shop.activityList.map((activity, idx) => {
                let src = '';
                if (activity.type == 1) {
                  //团餐
                  src = pTuancanbiaoqian;
                }
                if (activity.isShow == 1) {
                  return <Image className="tcIcon" src={src} key={'localOrgActivity' + idx} />;
                } else {
                  return null;
                }
              })}
            <View className="left">
              <Imagelocation className="shopIcon" src={shop.logo} type="shop" />
            </View>
            <View className="right">
              <View className="name">{shop.name}</View>
              <View className="info">
                <View className="infoLeft">
                  <Image
                    className="starIcon"
                    src={typeof shop.grade !== 'undefined' ? pStar : ''}
                  />
                  <Text className="starNum">{shop.grade || ''}</Text>
                </View>
                <View className="infoRight">
                  <Text className="distance">
                    {typeof shop.distance !== 'undefined' ? shop.distance + 'km' : ''}
                  </Text>
                </View>
              </View>
              <View className="industry">{shop.secondIndustryName || ''}</View>
              <View className="notice">
                {shop.notice && shop.notice.length > 0 && (
                  <>
                    <Text>店铺</Text>
                    <Image className="noticeIcon" src={pNotice} />
                    <Text>：{shop.notice}</Text>
                  </>
                )}
              </View>
              {shop.policy && shop.policy.length > 0 && (
                <View className="manjianLine">
                  {shop.policy.map((item, index) => (
                    <Text className="manjian" key={'localOrgManjian' + index}>
                      {item}
                    </Text>
                  ))}
                </View>
              )}
            </View>
          </View>
        ))}
    </View>
  );
};

export default ShopList;
